import { LOAD_VIDEO, SHOW_VIDEO_PAGE, BIND_VIDEO } from "../actions/video.action";

let initialState = {
    showVideoPage: false,
    curVideo: {
        vid: ''
    },
    dom: null,
    isPlaying: true,
    playRecord: {}
};

export default (state=initialState, action) => {
    switch (action.type) {
        case SHOW_VIDEO_PAGE:
            if (!action.bool && state.dom) state.dom.pause();             
            return {
                ...state,
                showVideoPage: action.bool
            }
        case LOAD_VIDEO:
            let curVideo = action.item;
            return {
                ...state,
                curVideo
            }
        case BIND_VIDEO:
            let dom = action.videoEle;
            return {
                ...state,
                dom
            }
        default:
            return state;
    }
}   